package com.zx.tradeclient.ctrl.index5;

import java.util.ArrayList;
import java.util.List;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.LinearLayout;

import com.zx.base.ctrl.BaseActivity;
import com.zx.base.util.ActivityTaskManager;
import com.zx.base.widget.SlidingPage;
import com.zx.base.widget.SlidingPage.SlidingPagerAdapter;
import com.zx.base.widget.SlidingPage.ViewPagerSelectListener;
import com.zx.tradeclient.R;

public class OrderPageActivity extends BaseActivity implements OnClickListener{
	/** Called when the activity is first created. */
	
	private SlidingPage page;
	private LinearLayout page_layout;
	private BuyerOrderList buyerorderList;
	private SellerOrderList sellerorderlist;
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.listindex);
		setHeader(0);
		if(!(ActivityTaskManager.getInstance().containsName("Index2Activity"))){
			ActivityTaskManager.getInstance().putActivity("Index2Activity", this);
		}

		init();
	}

	private void init() {
		LayoutInflater mInflater = getLayoutInflater();
		String[] titles = new String[] {"我是买家","我是卖家" };
		page = new SlidingPage(this, 2, R.drawable.page_slider_2);
		page.setTitles(titles);
		setHeader(0);
		page_layout = (LinearLayout) findViewById(R.id.list_main_layout);
		page_layout.addView(page);
		final List<View> listViews = new ArrayList<View>();
		listViews.add(mInflater.inflate(R.layout.list, null));
		listViews.add(mInflater.inflate(R.layout.list, null));
		page.getViewPager().setAdapter(new SlidingPagerAdapter(listViews));
		page.setViewPageSelectedListener(new ViewPagerSelectListener() {
			
			@Override
			public void pageSelected(int current) {
				View view = listViews.get(current);
				switch (current) {
				case 0:
					if(buyerorderList==null)
					buyerorderList=new BuyerOrderList(OrderPageActivity.this,view);

					break;
				case 1:
					if(sellerorderlist==null)
					sellerorderlist=new SellerOrderList(OrderPageActivity.this,view);
					
					break;
				
				default:
					break;
				}

			}
		});
		
		page.getViewPager().setCurrentItem(0, false);
		page.getViewPageSelectedListener().pageSelected(0);

	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		
	}
	


}